home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Amiga
/
Applications
/
Musique
/
ays-t23d.lha
/
BoNuS @ thx.home.ml.org
/
SEA-THXR.LHA
/
thxplay.e
< prev
next >
Wrap
Text File
|
1998-03-01
|
8KB
|
305 lines
OPT OSVERSION=37,PREPROCESS
MODULE 'gadtools',
'libraries/gadtools',
'exec/memory',
'exec/ports',
'exec/lists',
'exec/nodes',
'graphics/modeid',
'graphics/rastport',
'intuition/intuition',
'intuition/screens',
'intuition/gadgetclass',
'intuition/iobsolete',
'utility/tagitem',
'devices/inputevent',
'graphics/text'
MODULE 'diskfont'
MODULE '*thxplayver',
'dos/dos',
'thx/thx-play',
'tools/file'
DEF tmp[100]:STRING,
fname[100]:STRING
DEF m,l,i
/* GadToolsBox GUI: E source generated by SrcGen v0.5 */
/* (by Wouter & Martin Kuchinka & Jason) */
ENUM ERROR_NONE,
ERROR_CONTEXT,
ERROR_GADGET,
ERROR_SCRN,
ERROR_VISUAL,
ERROR_GT,
ERROR_WINDOW,
ERROR_MENUS,
ERROR_PORT,
ERROR_DF,
ERROR_FONT
DEF infos:PTR TO gadget,
project0wnd:PTR TO window,
project0glist,
font=NIL,
scr=NIL:PTR TO screen,
visual=NIL,
offx,offy,
tattr:PTR TO textattr,
type,id,key,qual,item:PTR TO menuitem
-> ***************************
-> Start of templates section.
-> (Return FALSE to quit the GUI.)
-> Templates for window "project0":
PROC project0_CloseWindow()
-> Routine for "IDCMP_CLOSEWINDOW".
ENDPROC FALSE
PROC gadget00_Clicked()
-> Routine when gadget "<" is clicked.
ENDPROC TRUE
PROC gadget10_Clicked()
-> Routine when gadget "Play" is clicked.
thxPlay()
FOR i:=1 TO 64
Delay(2)
thxSetVolume(i)
ENDFOR
ENDPROC TRUE
PROC gadget20_Clicked()
-> Routine when gadget "Stop" is clicked.
FOR i:=64 TO 0 STEP -1
WaitTOF()
thxSetVolume(i)
ENDFOR
thxFree()
ENDPROC FALSE
PROC gadget30_Clicked()
-> Routine when gadget ">" is clicked.
ENDPROC TRUE
-> End of templates section.
-> *************************
PROC setupscreen()
IF (gadtoolsbase:=OpenLibrary('gadtools.library',37))=NIL THEN RETURN ERROR_GT
IF (diskfontbase:=OpenLibrary('diskfont.library',0))=NIL THEN RETURN ERROR_DF
font:=OpenDiskFont(tattr:=['topaz.font',8,0,$1]:textattr)
CloseLibrary(diskfontbase)
IF font=NIL THEN RETURN ERROR_FONT
IF (scr:=LockPubScreen(NIL))=NIL THEN RETURN ERROR_SCRN
IF (visual:=GetVisualInfoA(scr,NIL))=NIL THEN RETURN ERROR_VISUAL
offx:=scr.wborleft
offy:=scr.wbortop+scr.rastport.txheight+1
ENDPROC
PROC closedownscreen()
IF visual THEN FreeVisualInfo(visual)
IF scr THEN UnlockPubScreen(NIL,scr)
IF font THEN CloseFont(font)
IF gadtoolsbase THEN CloseLibrary(gadtoolsbase)
ENDPROC
PROC openproject0window(port)
DEF g:PTR TO gadget
IF (g:=CreateContext({project0glist}))=NIL THEN RETURN ERROR_CONTEXT
IF (g:=CreateGadgetA(BUTTON_KIND,g,
[offx+8,offy+2,62,13,'<',tattr,0,PLACETEXT_IN,visual,{gadget00_Clicked}]:newgadget,
[GA_DISABLED,TRUE,
TAG_END]))=NIL THEN RETURN ERROR_GADGET
IF (g:=CreateGadgetA(BUTTON_KIND,g,
[offx+70,offy+2,62,13,'Play',tattr,1,PLACETEXT_IN,visual,{gadget10_Clicked}]:newgadget,
[TAG_END]))=NIL THEN RETURN ERROR_GADGET
IF (g:=CreateGadgetA(BUTTON_KIND,g,
[offx+132,offy+2,62,13,'Stop',tattr,2,PLACETEXT_IN,visual,{gadget20_Clicked}]:newgadget,
[TAG_END]))=NIL THEN RETURN ERROR_GADGET
IF (g:=CreateGadgetA(BUTTON_KIND,g,
[offx+194,offy+2,62,13,'>',tattr,3,PLACETEXT_IN,visual,{gadget30_Clicked}]:newgadget,
[GA_DISABLED,TRUE,
TAG_END]))=NIL THEN RETURN ERROR_GADGET
IF (project0wnd:=OpenWindowTagList(NIL,
[WA_LEFT,180,
WA_TOP,offy+45,
WA_WIDTH,offx+272,
WA_HEIGHT,offy+20,
WA_IDCMP,0,
WA_FLAGS,WFLG_SMART_REFRESH,
WA_TITLE,'Play module..',
WA_CUSTOMSCREEN,scr,
WA_MINWIDTH,67,
WA_MINHEIGHT,21,
WA_MAXWIDTH,$280,
WA_MAXHEIGHT,256,
WA_AUTOADJUST,TRUE,
WA_NEWLOOKMENUS,TRUE,
WA_GADGETS,project0glist,
TAG_END]))=NIL THEN RETURN ERROR_WINDOW
project0wnd.userport:=port
ModifyIDCMP(project0wnd,IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW)
project0wnd.userdata:=[{project0_CloseWindow},0,0,0,0]
DrawBevelBoxA(project0wnd.rport,offx+0,offy+0,268,18,
[GT_VISUALINFO,visual,TAG_END])
Gt_RefreshWindow(project0wnd,NIL)
ENDPROC
PROC closeproject0window()
IF project0wnd
clearwinport(project0wnd)
IF project0wnd.userdata THEN Dispose(project0wnd.userdata)
CloseWindow(project0wnd)
ENDIF
IF project0glist THEN FreeGadgets(project0glist)
ENDPROC
PROC clearwinport(win:PTR TO window)
DEF msg:PTR TO intuimessage, succ
IF win.userport
Forbid()
msg:=win.userport.msglist.head
WHILE succ:=msg.execmessage.ln.succ
IF msg.idcmpwindow=win
Remove(msg)
ReplyMsg(msg)
ENDIF
msg:=succ
ENDWHILE
win.userport:=NIL
ModifyIDCMP(win,0)
Permit()
ENDIF
ENDPROC
PROC multiprocess(sig)
DEF win:PTR TO window
DEF running=TRUE, func:PTR TO LONG
WHILE running
win:=multiwait4message(sig)
SELECT type
CASE IDCMP_CLOSEWINDOW
func:=win.userdata
IF func THEN func:=func[]
IF func THEN running:=func()
CASE IDCMP_GADGETUP
func:=infos.userdata
IF func THEN running:=func()
CASE IDCMP_MENUPICK
WHILE infos<>MENUNULL
item:=ItemAddress(win.menustrip,infos)
func:=GTMENUITEM_USERDATA(item)
IF func THEN running:=func()
EXIT running=FALSE
infos:=item.nextselect AND $FFFF
ENDWHILE
CASE IDCMP_IDCMPUPDATE
func:=win.userdata
IF func THEN func:=func[1]
IF func THEN running:=func()
CASE IDCMP_INTUITICKS
func:=win.userdata
IF func THEN func:=func[2]
IF func THEN running:=func()
CASE IDCMP_MOUSEBUTTONS
func:=win.userdata
IF func THEN func:=func[3]
IF func THEN running:=func()
CASE IDCMP_VANILLAKEY
func:=win.userdata
IF func THEN func:=func[4]
IF func THEN running:=func()
ENDSELECT
ENDWHILE
ENDPROC
PROC multiwait4message(port)
DEF win:PTR TO window,mes:PTR TO intuimessage
REPEAT
type:=0
IF mes:=Gt_GetIMsg(port)
win:=mes.idcmpwindow
type:=mes.class
SELECT type
CASE IDCMP_MENUPICK
infos:=mes.code
CASE IDCMP_GADGETUP
infos:=mes.iaddress
id:=infos.gadgetid
CASE IDCMP_VANILLAKEY
key:=mes.code
qual:=mes.qualifier AND $FFFF
CASE IDCMP_MOUSEBUTTONS
qual:=mes.qualifier AND $FFFF
CASE IDCMP_REFRESHWINDOW
Gt_BeginRefresh(win)
Gt_EndRefresh(win,TRUE)
type:=0
ENDSELECT
Gt_ReplyIMsg(mes)
ELSE
WaitPort(port)
ENDIF
UNTIL type
ENDPROC win
PROC reporterr(er)
DEF erlist:PTR TO LONG
IF er
erlist:=['get context',
'create gadget',
'lock/open screen',
'get visual infos',
'open "gadtools.library" v37+',
'open window',
'create menus',
'create port',
'open "diskfont.library"',
'open font']
EasyRequestArgs(0,[20,0,0,'Could not \s!','OK'],0,[erlist[er-1]])
ENDIF
ENDPROC er
PROC main() HANDLE
DEF err=ERROR_NONE,port=NIL
IF InStr(arg,'"',0)>=0
MidStr(tmp,arg,1,StrLen(arg)-2)
StrCopy(fname,tmp,ALL)
ELSE
StrCopy(fname,arg,ALL)
ENDIF
WriteF('\n
THXPlay v1.4
by Dr. Ice SEA\n')
IF FileLength(fname)<10
WriteF('\nBad THX file, or file not found...\n')
CleanUp(0)
ENDIF
m,l:=readfile(fname,0,2)
thxInit(m)
thxSetVolume(0)
IF (port:=CreateMsgPort())=NIL THEN Raise(ERROR_PORT)
IF (err:=setupscreen())<>ERROR_NONE THEN Raise(err)
reporterr(openproject0window(port))
multiprocess(port)
closeproject0window()
EXCEPT DO
IF port THEN DeleteMsgPort(port)
closedownscreen()
reporterr(err)
ENDPROC